home *** CD-ROM | disk | FTP | other *** search
- '--------------------------------------------------------------------------
- ' Dialog2.vbs - Shows how to open and use dialogs from the WSH scripts.
- '
- ' REMARKS:
- ' - dialog resource must be located in the file that can be loaded with
- ' Win32 LoadLibrary() function (EXE, DLL, ...) or you can use empty
- ' dialog template located in the SGWINDOW.DLL module. In this case
- ' pass empty string as a first parameter for the DoModal method and
- ' string "DLG_EMPTY" as a dialog template name.
- '
- ' This file is part of the SG Window.
- ' Copyright (C) 1998 Stinga
- ' All rights reserved.
- '--------------------------------------------------------------------------
- option explicit
-
- ' Messages
- const wm_CLOSE = &H0010
- const wm_INITDIALOG = &H0110
- const wm_COMMAND = &H0111
-
- const ws_CHILD = &H40000000
- const ws_VISIBLE = &H10000000
- const ws_DISABLED = &H08000000
- const ws_CLIPSIBLINGS = &H04000000
- const ws_CLIPCHILDREN = &H02000000
- const ws_BORDER = &H00800000
- const ws_TABSTOP = &H00010000
-
- const WS_EX_CLIENTEDGE = &H00000200
-
- const ES_LEFT = &H0000
- const ES_CENTER = &H0001
- const ES_RIGHT = &H0002
- const ES_MULTILINE = &H0004
- const ES_UPPERCASE = &H0008
- const ES_LOWERCASE = &H0010
- const ES_PASSWORD = &H0020
- const ES_AUTOVSCROLL = &H0040
- const ES_AUTOHSCROLL = &H0080
- const ES_NOHIDESEL = &H0100
- const ES_OEMCONVERT = &H0400
- const ES_READONLY = &H0800
- const ES_WANTRETURN = &H1000
-
- const nCaptionHeight = 25
-
- ' Global declarations
- Dim g, dlg, rc, sResult
- Dim edit, ok
- Set dlg = WScript.CreateObject("SGWindow.Window", "dlg_")
- Set g = WScript.CreateObject("SGWindow.Globals")
- Set edit = WScript.CreateObject("SGWindow.Window")
- Set ok = WScript.CreateObject("SGWindow.Window")
-
- ' Show dialog
- rc = dlg.DoModal("", "DLG_EMPTY", 100, 100)
-
- Wscript.DisconnectObject dlg
- Set dlg = Nothing
- Set edit = Nothing
- Set ok = Nothing
- Set g = Nothing
-
- MsgBox sResult
- WScript.Quit
-
- '--------------------------------------------------------------------------
- ' Dialog window procedure
- '--------------------------------------------------------------------------
- Sub dlg_Message(msg, wParam, lParam, result)
- result = 0
-
- select case msg
- case wm_INITDIALOG
- Dim style
- style = WS_CHILD + WS_VISIBLE + WS_BORDER + WS_TABSTOP
-
- ' Create edit box
- edit.Create "EDIT", "", style + ES_AUTOHSCROLL, _
- WS_EX_CLIENTEDGE, 10, 10, dlg.Width-25, 23, dlg.hWnd, 100
- edit.hFont = dlg.hFont
- edit.Text = "This edit box was created by VBScript"
-
- ' Create OK button
- ok.Create "BUTTON", "OK", style, 0, _
- 10, dlg.Height - nCaptionHeight - 40, 80, 30, dlg.hWnd, 1
- ok.hFont = dlg.hFont
-
- case wm_CLOSE
- sResult = "Closed"
- dlg.EndDialog 0
-
- case wm_COMMAND
- Dim bHandled
- bHandled = OnCommand(g.HighWord(wParam), g.LowWord(wParam), lParam)
- if Not bHandled Then
- result = dlg.CallWindowProc(msg, wParam, lParam)
- end if
-
- case else
- result = dlg.CallWindowProc(msg, wParam, lParam)
- end select
- End Sub
-
- '--------------------------------------------------------------------------
- ' Handle dialog WM_COMMAND messages
- '--------------------------------------------------------------------------
- Private Function OnCommand(notifyCode, id, hwnd)
- OnCommand = false
- select case id
- case 1 ' OK
- dlg.EndDialog 1
- OnCommand = true
-
- case 2 ' CANCEL
- 'dlg.EndDialog 2
- 'OnCommand = True
-
- case 100 ' EditBox
- end select
- End Function
-
-